import http from '../../util/request.js';
var WxParse = require('../../../wxParse/wxParse.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var n = wx.getStorageSync("barlist");
    if (n) {
      this.setData({
        pro: n.pro
      });
    }
    var backgroundColor = n.pro.backgroundColor != undefined ? n.pro.backgroundColor : '#000000';
    var frontColor = n.pro.frontColor != undefined ? n.pro.frontColor : '#ffffff';
      wx.setNavigationBarColor({
        frontColor: frontColor,
        backgroundColor: backgroundColor
      });

    var that = this;
    var id = options.id;
    http.get('article', {
      act: 'detail',
      id: id
    }).then(function (res) {
      that.setData({
        detail: res
      });
      WxParse.wxParse('article', 'html', res.content, that, 0);
    });
  },
  goToUrl: function (e) {
    var that = this;
    var url = e.currentTarget.dataset.url;
    wx.reLaunch({
      url: url,
    })
  },
  onShareAppMessage: function (res) {
    return {
      title: this.data.detail.title,
      page: 'weidun_card/pages/detail/detail?id='+this.data.detail.id,
      imageUrl:this.data.detail.thumb
    }
  }
})